$webwork.htmlEncode($page.space.name) : KML KMZ Output
This page last changed on Jul 24, 2007 by cholmes.
Quickstart QuickstartTo get started with GeoServer and Google Earth right away simply type a wms / kml url into your web browser and open the result with Google Earth. An alternative is to add the data directly in Google Earth via a Network Link: When adding the network link directly in Google Earth it is possible to set a number of parameters which control how the data is handled by Google Earth. Here are some good defaults:
KML and KMZ OutputGeoServer supports both KML and KMZ output for WMS requests so data can be served up to Google Eearth. KML is vector output, and KMZ (KML Zipped) will contain raster images of the data instead of vector data. To return KML in a WMS getMap request, just set the "format" value to application/vnd.google-earth.kml+XML. For example: To return KMZ in a WMS getMap request, just set the "format" value to application/vnd.google-earth.kmz. For example: Vector vs. RasterVector data looks the best and is the most detailed at all zoom levels, but it can be quite big and cumbersome if the dataset is large. In that case, it is preferred to use raster images of the data instead (like a normal PNG WMS map request). When you ask for KMZ output, you can pass in the KMSCORE value as a parameter, and the server will determine whether it gives you KML (vector) or KMZ (raster) results.
Geoserver is smart enough to make the call between vector and raster output: there is a definite point where one will be larger than the other, depending on how much data is queried. The KMScore parameter is an integer between 0 and 100. It is an exponential value, meaning that the higher the KMScore value, the more features are required to return a raster output. Here are some example values:
Here is the formula used to determine the feature threshold: The server is set at a default KMScore value of 40 (464 features). The same KMScore value is used on each layer, but each layer determines whether or not it has too many features to break the threshold, so some layers might be KML, and others might be KMZ. AttributionIt is possible to return full attribution on the data in the form of a description on the placemark values of each feature. By default it is turned on, but you can turn full attribution off by passing in the KMATTR parameter with the value "false".
KML ReflectorHave long and confusing WMS requests got you down? Do you not care what the parameters are and you just want a map back? Then the KML Reflector is for you! We've taken out the hard part of WMS requests (they aren't that hard, but still one more thing you have to learn) and take the liberty of filling in all the parameters for you. Of course, if you supply any of the parameters in the URL, they will be taken over our supplied defaults. To call the WMS reflector, you just need to point to your server location and pass in one parameter: 'layers'.
So instead of a request to "<server>/geoserver/wms?parameters", you send the request to "<server>/geoserver/wms/kml_reflect?layers=myLayer". To test this out, create a new network link, like above, but change the URL to http://localhost:8080/geoserver/wms/kml_reflect?layers=states
The default image width and height are both 1024 pixels. The network link that is returned will also be configured for 'view-based refresh' with a delay of 3 seconds. So an automatic viewing bounding box will be submitted and you won't need to add your own. Using the KML Reflector is by far the easiest way to serve data up to Google Earth from GeoServer. Region Based KMLKML supports the notion of regions in which the map or view area is divided up into sections. This allows Google Earth to refresh/request only particular sections of the map when say the view area changes, which is much more efficient then requesting/refreshing all the data over again. This is similar in notion to the concept of tiling. Similar to tiles, regions fall into a hierarchy in which one region is made up of a number of smaller regions. To instruct GeoServer to return region based kml simply append the parameter superoverlay=true to a kml request. For example: As you zoom into particular portions of the map you will notice that only those regions that fall within the camera view area are refreshed. This form of region based kml has a number of benefits. The first is described above in that it allows Google Earth to only re-request portions of data when the view changes. Which for large datasets can lead to a major performance improvement. Tile CachingThe second benefit of using region based kml has to do with tile caching. GeoServer returns KML regions that are consistent with the WMS Tiling Specification which means that Google Earth will request the same regions that a tiling WMS client will. So if you are using GeoServer with a tile caching server you will reap the same performance benefits! To configure region based kml to be used in conjunction with TileCache:
You can set the TileCache parameter to an absolute location like "http://sigma.openplans.org/tilecache/tilecache.py?" or you can set it to a relative location like "tilecache/tilecache.py?". The latter will be interpreted as relative to the same host GeoServer is running on. Be sure that you have the latest version of TileCache installed, as there are a few incompatibilities in earlier versions. KML LegendsUsing a combination of the WMS GetLegendGraphic operation and KML overlays GeoServer supports legends. To add a legend simply append the legend=true parameter to the kml request. For example:
kml_tutorial.jpg (image/jpeg)
addNetworkLink.png (image/png) addNetworkLink.png (image/png) addNetworkLink.png (image/png) newNetworkLink.png (image/png) newNetworkLink.png (image/png) browser.png (image/png) tilecache.png (image/png) tilecache.png (image/png) |
Document generated by Confluence on Jan 16, 2008 23:27 |